<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>JavaScript基础 | Plain-ww</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/Blogs/image/favicon.ico">
    <script>
            var _hmt = _hmt || [];
            (function() {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?075adfc465e73bf946e90d4c1e1daef8";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();</script>
    <meta name="description" content="嘘~正在加载中····">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/Blogs/assets/css/0.styles.8be25012.css" as="style"><link rel="preload" href="/Blogs/assets/js/app.f9a70f72.js" as="script"><link rel="preload" href="/Blogs/assets/js/3.e5a0ba5b.js" as="script"><link rel="preload" href="/Blogs/assets/js/1.1a4801d9.js" as="script"><link rel="preload" href="/Blogs/assets/js/16.736c5c7b.js" as="script"><link rel="prefetch" href="/Blogs/assets/js/10.309ff4ae.js"><link rel="prefetch" href="/Blogs/assets/js/11.ec1b3478.js"><link rel="prefetch" href="/Blogs/assets/js/12.4bcfe366.js"><link rel="prefetch" href="/Blogs/assets/js/13.febe69a7.js"><link rel="prefetch" href="/Blogs/assets/js/14.b3e2faee.js"><link rel="prefetch" href="/Blogs/assets/js/15.ff4f6956.js"><link rel="prefetch" href="/Blogs/assets/js/17.c845af3a.js"><link rel="prefetch" href="/Blogs/assets/js/18.6e029a91.js"><link rel="prefetch" href="/Blogs/assets/js/19.cd97261c.js"><link rel="prefetch" href="/Blogs/assets/js/20.a22a6b9a.js"><link rel="prefetch" href="/Blogs/assets/js/21.b977b09b.js"><link rel="prefetch" href="/Blogs/assets/js/4.c0b52bb0.js"><link rel="prefetch" href="/Blogs/assets/js/5.02c66228.js"><link rel="prefetch" href="/Blogs/assets/js/6.a1ff653a.js"><link rel="prefetch" href="/Blogs/assets/js/7.2ce62b93.js"><link rel="prefetch" href="/Blogs/assets/js/8.47e00f72.js"><link rel="prefetch" href="/Blogs/assets/js/9.c40d9138.js">
    <link rel="stylesheet" href="/Blogs/assets/css/0.styles.8be25012.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-1156296a><div data-v-1156296a><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-1156296a data-v-1156296a><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-4e82dffc data-v-1156296a data-v-1156296a><h3 class="title" data-v-4e82dffc data-v-4e82dffc>Plain-ww</h3> <p class="description" data-v-4e82dffc data-v-4e82dffc>嘘~正在加载中····</p> <label id="box" class="inputBox" data-v-4e82dffc data-v-4e82dffc><input type="password" value="" data-v-4e82dffc> <span data-v-4e82dffc>Konck! Knock!</span> <button data-v-4e82dffc>OK</button></label> <div class="footer" data-v-4e82dffc data-v-4e82dffc><span data-v-4e82dffc><i class="iconfont reco-theme" data-v-4e82dffc></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-4e82dffc>vuePress-theme-reco</a></span> <span data-v-4e82dffc><i class="iconfont reco-copyright" data-v-4e82dffc></i> <a data-v-4e82dffc><span data-v-4e82dffc>Wwei</span>
            
          <span data-v-4e82dffc>2020 - </span>
          2021
        </a></span></div></div> <div class="hide" data-v-1156296a><header class="navbar" data-v-1156296a><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/Blogs/" class="home-link router-link-active"><img src="/Blogs/image/logo.png" alt="Plain-ww" class="logo"> <span class="site-name">Plain-ww</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/Blogs/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/Blogs/categories/后端/" class="nav-link"><i class="undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/Blogs/categories/前端/" class="nav-link"><i class="undefined"></i>
  前端
</a></li><li class="dropdown-item"><!----> <a href="/Blogs/categories/随笔/" class="nav-link"><i class="undefined"></i>
  随笔
</a></li></ul></div></div><div class="nav-item"><a href="/Blogs/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-document"></i>
      其他
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>项目</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/Blogs/docs/theme-reco/" class="nav-link"><i class="undefined"></i>
  后台管理系统
</a></li></ul></li><li class="dropdown-item"><h4>在线编辑</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://tinypng.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  图片压缩
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>在线服务</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://www.aliyun.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  阿里云
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://cloud.tencent.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  腾讯云
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>博客指南</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://juejin.im/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  掘金
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://blog.csdn.net/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  CSDN
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><a href="/Blogs/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/Blogs/docs/theme-reco/" class="nav-link"><i class="iconfont reco-account"></i>
  关于我
</a></div><div class="nav-item"><a href="https://github.com/Plain-ww" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-1156296a></div> <aside class="sidebar" data-v-1156296a><div class="personal-info-wrapper" data-v-828910c6 data-v-1156296a><img src="/Blogs/image/weixing.png" alt="author-avatar" class="personal-img" data-v-828910c6> <h3 class="name" data-v-828910c6>
    Wwei
  </h3> <div class="num" data-v-828910c6><div data-v-828910c6><h3 data-v-828910c6>11</h3> <h6 data-v-828910c6>Articles</h6></div> <div data-v-828910c6><h3 data-v-828910c6>6</h3> <h6 data-v-828910c6>Tags</h6></div></div> <ul class="social-links" data-v-828910c6></ul> <hr data-v-828910c6></div> <nav class="nav-links"><div class="nav-item"><a href="/Blogs/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/Blogs/categories/后端/" class="nav-link"><i class="undefined"></i>
  后端
</a></li><li class="dropdown-item"><!----> <a href="/Blogs/categories/前端/" class="nav-link"><i class="undefined"></i>
  前端
</a></li><li class="dropdown-item"><!----> <a href="/Blogs/categories/随笔/" class="nav-link"><i class="undefined"></i>
  随笔
</a></li></ul></div></div><div class="nav-item"><a href="/Blogs/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-document"></i>
      其他
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>项目</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/Blogs/docs/theme-reco/" class="nav-link"><i class="undefined"></i>
  后台管理系统
</a></li></ul></li><li class="dropdown-item"><h4>在线编辑</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://tinypng.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  图片压缩
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>在线服务</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://www.aliyun.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  阿里云
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://cloud.tencent.com/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  腾讯云
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>博客指南</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://juejin.im/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  掘金
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://blog.csdn.net/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="undefined"></i>
  CSDN
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><a href="/Blogs/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><a href="/Blogs/docs/theme-reco/" class="nav-link"><i class="iconfont reco-account"></i>
  关于我
</a></div><div class="nav-item"><a href="https://github.com/Plain-ww" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-4e82dffc data-v-1156296a><h3 class="title" data-v-4e82dffc data-v-4e82dffc>JavaScript基础</h3> <!----> <label id="box" class="inputBox" data-v-4e82dffc data-v-4e82dffc><input type="password" value="" data-v-4e82dffc> <span data-v-4e82dffc>Konck! Knock!</span> <button data-v-4e82dffc>OK</button></label> <div class="footer" data-v-4e82dffc data-v-4e82dffc><span data-v-4e82dffc><i class="iconfont reco-theme" data-v-4e82dffc></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-4e82dffc>vuePress-theme-reco</a></span> <span data-v-4e82dffc><i class="iconfont reco-copyright" data-v-4e82dffc></i> <a data-v-4e82dffc><span data-v-4e82dffc>Wwei</span>
            
          <span data-v-4e82dffc>2020 - </span>
          2021
        </a></span></div></div> <div data-v-1156296a><main class="page"><section><div class="page-title"><h1 class="title">JavaScript基础</h1> <div data-v-1ff7123e><i class="iconfont reco-account" data-v-1ff7123e><span data-v-1ff7123e>Wwei</span></i> <i class="iconfont reco-date" data-v-1ff7123e><span data-v-1ff7123e>5/2/2021</span></i> <i class="iconfont reco-eye" data-v-1ff7123e><span id="/Blogs/blogs/qianduan/JavaScript/JavaScript.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-1ff7123e><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="tags iconfont reco-tag" data-v-1ff7123e><span class="tag-item" data-v-1ff7123e>JavaScript</span></i></div></div> <div class="theme-reco-content content__default"><h2 id="_1-编程语言"><a href="#_1-编程语言" class="header-anchor">#</a> 1 - 编程语言</h2> <h3 id="_1-1-编程"><a href="#_1-1-编程" class="header-anchor">#</a> 1.1 编程</h3> <ul><li>编程：
<ul><li>就是让计算机为解决某个问题而使用某种程序设计语言编写程序代码，并最终得到结果的过程。</li></ul></li> <li>计算机程序：
<ul><li>就是计算机所执行的一系列的指令集合，而程序全部都是用我们所掌握的语言来编写的，所以人们要控制计算机一定要通过计算机语言向计算机发出命令。</li></ul></li></ul> <h3 id="_1-2-计算机语言"><a href="#_1-2-计算机语言" class="header-anchor">#</a> 1.2 计算机语言</h3> <ul><li><p>计算机语言指用于人与计算机之间通讯的语言，它是人与计算机之间传递信息的媒介。</p></li> <li><p>计算机语言的种类非常的多，总的来说可以分成机器语言，汇编语言和高级语言三大类。</p></li> <li><p>实际上计算机最终所执行的都是 机器语言，它是由“0”和“1”组成的二进制数，二进制是计算机语言的基础。</p> <p><img src="images%5C%E5%9B%BE%E7%89%871.png" alt=""></p></li></ul> <h3 id="_1-3-编程语言"><a href="#_1-3-编程语言" class="header-anchor">#</a> 1.3 编程语言</h3> <div class="language-html line-numbers-mode"><pre class="language-html"><code>编程语言：
	可以通过类似于人类语言的“语言”来控制计算机，让计算机为我们做事情，这样的语言就叫做编程语言（Programming Language）。编程语言是用来控制计算机的一系列指令，它有固定的格式和词汇（不同编程语言的格式和词汇不一样），必须遵守。如今通用的编程语言有两种形式：汇编语言和高级语言。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><table><thead><tr><th>语言类型</th> <th style="text-align:center;">说明</th></tr></thead> <tbody><tr><td><strong>汇编语言</strong></td> <td style="text-align:center;">汇编语言和机器语言实质是相同的，都是直接对硬件操作，只不过指令采用了英文缩写的标识符，容易识别和记忆。</td></tr> <tr><td><strong>高级语言</strong></td> <td style="text-align:center;">高级语言主要是相对于低级语言而言，它并不是特指某一种具体的语言，而是包括了很多编程语言，常用的有C语言、C++、Java、C#、Python、PHP、JavaScript、Go语言、Objective-C、Swift等。</td></tr></tbody></table> <p><img src="images%5C%E5%9B%BE%E7%89%872.png" alt=""></p> <h3 id="_1-4-翻译器"><a href="#_1-4-翻译器" class="header-anchor">#</a> 1.4 翻译器</h3> <div class="language- extra-class"><pre><code>	高级语言所编制的程序不能直接被计算机识别，必须经过转换才能被执行，为此，我们需要一个翻译器。翻译器可以将我们所编写的源代码转换为机器语言，这也被称为二进制化。
</code></pre></div><p><img src="images%5C%E5%9B%BE%E7%89%873.png" alt=""></p> <h3 id="_1-5-编程语言和标记语言区别"><a href="#_1-5-编程语言和标记语言区别" class="header-anchor">#</a> 1.5 编程语言和标记语言区别</h3> <table><thead><tr><th>语言</th> <th>说明</th></tr></thead> <tbody><tr><td>编程语言</td> <td>编程语言有很强的逻辑和行为能力。在编程语言里, 你会看到很多 if else 、for 、while等具有逻辑性和行为能力的指令，这是主动的。</td></tr> <tr><td>标记语言</td> <td>标记语言（html）不用于向计算机发出指令，常用于格式化和链接。标记语言的存在是用来被读取的, 他是被动的。</td></tr></tbody></table> <h3 id="总结"><a href="#总结" class="header-anchor">#</a> 总结</h3> <ol><li>计算机可以帮助人类解决某些问题</li> <li>程序员利用编程语言编写程序发出指令控制计算机来实现这些任务</li> <li>编程语言有机器语言、汇编语言、高级语言</li> <li>高级语言需要一个翻译器转换为计算机识别的机器语言</li> <li>编程语言是主动的有很强的逻辑性</li></ol> <h2 id="_2-计算机基础"><a href="#_2-计算机基础" class="header-anchor">#</a> 2 - 计算机基础</h2> <h3 id="_2-1-计算机组成"><a href="#_2-1-计算机组成" class="header-anchor">#</a> 2.1 计算机组成</h3> <p><img src="images%5C%E5%9B%BE%E7%89%874.png" alt=""></p> <p><img src="images%5C%E5%9B%BE%E7%89%875.png" alt=""></p> <h3 id="_2-2-数据存储"><a href="#_2-2-数据存储" class="header-anchor">#</a> 2.2 数据存储</h3> <ol><li>计算机内部使用二进制 0 和 1来表示数据。</li> <li>所有数据，包括文件、图片等最终都是以二进制数据（0 和 1）的形式存放在硬盘中的。</li> <li>所有程序，包括操作系统，本质都是各种数据，也以二进制数据的形式存放在硬盘中。平时我们所说的安装软件，其实就是把程序文件复制到硬盘中。</li> <li>硬盘、内存都是保存的二进制数据。</li></ol> <h3 id="_2-3-数据存储单位"><a href="#_2-3-数据存储单位" class="header-anchor">#</a> 2.3 数据存储单位</h3> <div class="language- line-numbers-mode"><pre class="language-text"><code>大小关系：bit &lt; byte &lt; kb &lt; GB &lt; TB&lt;.....
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>位(bit)：   1bit 可以保存一个 0 或者 1 （最小的存储单位）</li> <li>字节(Byte)：1B = 8b</li> <li>千字节(KB)：1KB = 1024B</li> <li>兆字节(MB)：1MB = 1024KB</li> <li>吉字节(GB):  1GB = 1024MB</li> <li>太字节(TB):  1TB = 1024GB</li></ul> <h3 id="_2-4-程序运行"><a href="#_2-4-程序运行" class="header-anchor">#</a> 2.4 程序运行</h3> <p><img src="images%5C%E5%9B%BE%E7%89%876.png" alt=""></p> <div class="language- extra-class"><pre><code>计算机运行软件的过程：
1. 打开某个程序时，先从硬盘中把程序的代码加载到内存中
2. CPU执行内存中的代码
   注意：之所以要内存的一个重要原因，是因为 cpu运行太快了，如果只从硬盘中读数据，会浪费cpu性能，所以，才使用存取速度更快的内存来保存运行时的数据。（内存是电，硬盘是机械）
</code></pre></div><h2 id="_3-初始javascript"><a href="#_3-初始javascript" class="header-anchor">#</a> 3 - 初始JavaScript</h2> <h3 id="_3-1-javascript-是什么"><a href="#_3-1-javascript-是什么" class="header-anchor">#</a> 3.1 JavaScript 是什么</h3> <p><img src="images%5C%E5%9B%BE%E7%89%877.png" alt=""></p> <ul><li><p>JavaScript 是世界上最流行的语言之一，是一种运行在客户端的脚本语言 （Script 是脚本的意思）</p></li> <li><p>脚本语言：不需要编译，运行过程中由 js 解释器( js 引擎）逐行来进行解释并执行</p></li> <li><p>现在也可以基于 Node.js 技术进行服务器端编程</p> <p><img src="images%5C%E5%9B%BE%E7%89%878.png" alt=""></p></li></ul> <h3 id="_3-2-javascript的作用"><a href="#_3-2-javascript的作用" class="header-anchor">#</a> 3.2 JavaScript的作用</h3> <ul><li>表单动态校验（密码强度检测）  （ JS 产生最初的目的 ）</li> <li>网页特效</li> <li>服务端开发(Node.js)</li> <li>桌面程序(Electron)</li> <li>App(Cordova)</li> <li>控制硬件-物联网(Ruff)</li> <li>游戏开发(cocos2d-js)</li></ul> <h3 id="_3-3-html-css-js-的关系"><a href="#_3-3-html-css-js-的关系" class="header-anchor">#</a> 3.3 HTML/CSS/JS 的关系</h3> <p><img src="images%5C%E5%9B%BE%E7%89%879.png" alt=""></p> <h3 id="_3-4-浏览器执行-js-简介"><a href="#_3-4-浏览器执行-js-简介" class="header-anchor">#</a> 3.4 浏览器执行 JS 简介</h3> <p><strong>浏览器分成两部分：渲染引擎和 JS 引擎</strong></p> <p><img src="images%5Cneihe.png" alt=""></p> <div class="language- extra-class"><pre><code>	浏览器本身并不会执行JS代码，而是通过内置 JavaScript 引擎(解释器) 来执行 JS 代码 。JS 引擎执行代码时逐行解释每一句源码（转换为机器语言），然后由计算机去执行，所以 JavaScript 语言归为脚本语言，会逐行解释执行。
</code></pre></div><p><img src="images%5C%E5%9B%BE%E7%89%8710.png" alt=""></p> <h3 id="_3-5-js-的组成"><a href="#_3-5-js-的组成" class="header-anchor">#</a> 3.5 JS 的组成</h3> <p><img src="images%5C%E5%9B%BE%E7%89%8711.png" alt=""></p> <ol><li><h4 id="ecmascript"><a href="#ecmascript" class="header-anchor">#</a> <strong>ECMAScript</strong></h4> <p>​		ECMAScript 是由ECMA 国际（ 原欧洲计算机制造商协会）进行标准化的一门编程语言，这种语言在万维网上应用广泛，它往往被称为 JavaScript或 JScript，但实际上后两者是 ECMAScript 语言的实现和扩展。</p> <p><img src="images%5C%E5%9B%BE%E7%89%8712.png" alt=""></p> <p>​		ECMAScript：规定了JS的编程语法和基础核心知识，是所有浏览器厂商共同遵守的一套JS语法工业标准。</p> <p>更多参看MDN: <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/JavaScript_technologies_overview" target="_blank" rel="noopener noreferrer">MDN手册<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p></li> <li><h4 id="dom-文档对象模型"><a href="#dom-文档对象模型" class="header-anchor">#</a> <strong>DOM——文档对象模型</strong></h4> <p>​		<strong>文档对象模型</strong>（DocumentObject Model，简称DOM），是W3C组织推荐的处理可扩展标记语言的标准编程接口。通过 DOM 提供的接口可以对页面上的各种元素进行操作（大小、位置、颜色等）</p></li> <li><h4 id="bom-浏览器对象模型"><a href="#bom-浏览器对象模型" class="header-anchor">#</a> <strong>BOM——浏览器对象模型</strong></h4> <p>​		<strong>浏览器对象模型</strong>(Browser Object Model，简称BOM) 是指浏览器对象模型，它提供了独立于内容的、可以与浏览器窗口进行互动的对象结构。通过BOM可以操作浏览器窗口，比如弹出框、控制浏览器跳转、获取分辨率等。</p></li></ol> <h3 id="_3-6-js-初体验"><a href="#_3-6-js-初体验" class="header-anchor">#</a> 3.6 JS 初体验</h3> <div class="language- extra-class"><pre><code>JS 有3种书写位置，分别为行内、内嵌和外部。
</code></pre></div><ol><li>行内式</li></ol> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>button<span class="token punctuation">&quot;</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>点我试试<span class="token punctuation">&quot;</span></span> <span class="token attr-name">onclick</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>alert(<span class="token punctuation">'</span>Hello World<span class="token punctuation">'</span>)<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>可以将单行或少量 JS 代码写在HTML标签的事件属性中（以 on 开头的属性），如：onclick</li> <li>注意单双引号的使用：在HTML中我们推荐使用双引号, JS 中我们推荐使用单引号</li> <li>可读性差， 在html中编写JS大量代码时，不方便阅读；</li> <li>引号易错，引号多层嵌套匹配时，非常容易弄混；</li> <li>特殊情况下使用</li></ul> <ol start="2"><li><p>内嵌式</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
    <span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">'Hello  World~!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>可以将多行JS代码写到 script 标签中</li> <li>内嵌 JS 是学习时常用的方式</li></ul></li> <li><p>外部JS文件</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>my.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>利于HTML页面代码结构化，把大段 JS代码独立到 HTML 页面之外，既美观，也方便文件级别的复用</li> <li>引用外部 JS文件的 script 标签中间不可以写代码</li> <li>适合于JS 代码量比较大的情况</li></ul></li></ol> <h2 id="_4-javascript注释"><a href="#_4-javascript注释" class="header-anchor">#</a> 4 - JavaScript注释</h2> <ul><li>flex子项目占的份数</li> <li>align-self控制子项自己在侧轴的排列方式</li> <li>order属性定义子项的排列顺序（前后顺序）</li></ul> <h3 id="_4-1-单行注释"><a href="#_4-1-单行注释" class="header-anchor">#</a> 4.1  单行注释</h3> <div class="language- extra-class"><pre><code>为了提高代码的可读性，JS与CSS一样，也提供了注释功能。
JS中的注释主要有两种，分别是 单行注释 和 多行注释。
</code></pre></div><p>单行注释的注释方式如下：</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code>// 我是一行文字，不想被 JS引擎 执行，所以 注释起来	
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language- extra-class"><pre><code>// 用来注释单行文字（  快捷键   ctrl  +  /   ）
</code></pre></div><h3 id="_4-2-多行注释"><a href="#_4-2-多行注释" class="header-anchor">#</a> 4.2 多行注释</h3> <p>多行注释的注释方式如下：</p> <div class="language-html line-numbers-mode"><pre class="language-html"><code>/*
  获取用户年龄和姓名
  并通过提示框显示出来
*/
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><div class="language- line-numbers-mode"><pre class="language-text"><code>/* */  用来注释多行文字（ 默认快捷键  alt +  shift  + a ） 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>快捷键修改为：   ctrl + shift  +  /</p> <p>vscode → 首选项按钮 → 键盘快捷方式 → 查找 原来的快捷键 → 修改为新的快捷键 → 回车确认</p> <h2 id="_5-javascript输入输出语句"><a href="#_5-javascript输入输出语句" class="header-anchor">#</a> 5 - JavaScript输入输出语句</h2> <p>为了方便信息的输入输出，JS中提供了一些输入输出语句，其常用的语句如下：</p> <table><thead><tr><th>方法</th> <th>说明</th> <th>归属</th></tr></thead> <tbody><tr><td>alert(msg)</td> <td>浏览器弹出警示框</td> <td>浏览器</td></tr> <tr><td>console.log(msg)</td> <td>浏览器控制台打印输出信息</td> <td>浏览器</td></tr> <tr><td>prompt(info)</td> <td>浏览器弹出输入框，用户可以输入</td> <td>浏览器</td></tr></tbody></table> <ul><li>注意：alert() 主要用来显示消息给用户，console.log() 用来给程序员自己看运行时的消息。</li></ul> <h2 id="_6-变量的概念"><a href="#_6-变量的概念" class="header-anchor">#</a> 6 - 变量的概念</h2> <h3 id="_6-1-什么是变量"><a href="#_6-1-什么是变量" class="header-anchor">#</a> 6.1 什么是变量</h3> <p>白话：变量就是一个装东西的盒子。</p> <p>通俗：变量是用于存放数据的容器。 我们通过 变量名 获取数据，甚至数据可以修改。
<img src="images%5C%E5%9B%BE%E7%89%8713.png" alt=""></p> <h3 id="_6-2-变量在内存中的存储"><a href="#_6-2-变量在内存中的存储" class="header-anchor">#</a> 6.2 变量在内存中的存储</h3> <div class="language- extra-class"><pre><code>	本质：变量是程序在内存中申请的一块用来存放数据的空间。类似我们酒店的房间，一个房间就可以看做是一个变量。  
</code></pre></div><p><img src="images%5C%E5%9B%BE%E7%89%8714.png" alt=""></p> <h2 id="_7-变量的使用"><a href="#_7-变量的使用" class="header-anchor">#</a> 7 - 变量的使用</h2> <ul><li>变量的声明</li> <li>变量的赋值</li></ul> <h3 id="_7-1-声明变量"><a href="#_7-1-声明变量" class="header-anchor">#</a> 7.1 声明变量</h3> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token comment">//  声明变量  </span>
<span class="token keyword">var</span> age<span class="token punctuation">;</span> <span class="token comment">//  声明一个 名称为age 的变量     </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li><p>var 是一个 JS关键字，用来声明变量( variable 变量的意思 )。使用该关键字声明变量后，计算机会自动为变量分配内存空间，不需要程序员管</p></li> <li><p>age 是程序员定义的变量名，我们要通过变量名来访问内存中分配的空间</p></li></ul> <h3 id="_7-2-赋值"><a href="#_7-2-赋值" class="header-anchor">#</a> 7.2 赋值</h3> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code>age <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span> <span class="token comment">// 给 age  这个变量赋值为 10          </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>= 用来把右边的值赋给左边的变量空间中   此处代表赋值的意思</li> <li>变量值是程序员保存到变量空间里的值</li></ul> <h3 id="_7-3-变量的初始化"><a href="#_7-3-变量的初始化" class="header-anchor">#</a> 7.3 变量的初始化</h3> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> age  <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>  <span class="token comment">// 声明变量同时赋值为 18</span>
<span class="token comment">// 声明一个变量并赋值， 我们称之为变量的初始化。</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_7-4-变量语法扩展"><a href="#_7-4-变量语法扩展" class="header-anchor">#</a> 7.4 变量语法扩展</h3> <ul><li><p>更新变量</p> <p>​		一个变量被重新复赋值后，它原有的值就会被覆盖，变量值将以最后一次赋的值为准。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> age <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>

age <span class="token operator">=</span> <span class="token number">81</span><span class="token punctuation">;</span>   <span class="token comment">// 最后的结果就是81因为18 被覆盖掉了          </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div></li> <li><p>同时声明多个变量</p> <p>​		同时声明多个变量时，只需要写一个 var， 多个变量名之间使用英文逗号隔开。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> age <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">,</span>  name <span class="token operator">=</span> <span class="token string">'zs'</span><span class="token punctuation">,</span> sex <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>       
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li> <li><p>声明变量特殊情况</p> <table><thead><tr><th>情况</th> <th>说明</th> <th>结果</th></tr></thead> <tbody><tr><td>var  age ; console.log (age);</td> <td>只声明 不赋值</td> <td>undefined</td></tr> <tr><td>console.log(age)</td> <td>不声明 不赋值  直接使用</td> <td>报错</td></tr> <tr><td>age   = 10; console.log (age);</td> <td>不声明   只赋值</td> <td>10</td></tr></tbody></table></li></ul> <h3 id="_7-5-变量命名规范"><a href="#_7-5-变量命名规范" class="header-anchor">#</a> 7.5 变量命名规范</h3> <p>规则：</p> <ul><li>由字母(A-Za-z)、数字(0-9)、下划线(_)、美元符号( $ )组成，如：usrAge, num01, _name</li> <li>严格区分大小写。var app; 和 var App; 是两个变量</li> <li>不能 以数字开头。  18age   是错误的</li> <li>不能 是关键字、保留字。例如：var、for、while</li> <li>变量名必须有意义。 MMD   BBD        nl   →     age</li> <li>遵守驼峰命名法。首字母小写，后面单词的首字母需要大写。myFirstName<img src="images%5C%E5%9B%BE%E7%89%8715.png" alt=""></li></ul> <p>推荐翻译网站： 有道    爱词霸</p> <h2 id="_8-数据类型"><a href="#_8-数据类型" class="header-anchor">#</a> 8 - 数据类型</h2> <h3 id="_8-1-数据类型简介"><a href="#_8-1-数据类型简介" class="header-anchor">#</a> 8.1 数据类型简介</h3> <ul><li><p>为什么需要数据类型</p> <p>​		在计算机中，不同的数据所需占用的存储空间是不同的，为了便于把数据分成所需内存大小不同的数据，充分利用存储空间，于是定义了不同的数据类型。
简单来说，数据类型就是数据的类别型号。比如姓名“张三”，年龄18，这些数据的类型是不一样的。</p></li> <li><p>变量的数据类型</p> <p>​		变量是用来存储值的所在处，它们有名字和数据类型。变量的数据类型决定了如何将代表这些值的位存储到计算机的内存中。JavaScript 是一种弱类型或者说动态语言。这意味着不用提前声明变量的类型，在程序运行过程中，类型会被自动确定：</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> age <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span>        <span class="token comment">// 这是一个数字型</span>
<span class="token keyword">var</span> areYouOk <span class="token operator">=</span> <span class="token string">'是的'</span><span class="token punctuation">;</span>   <span class="token comment">// 这是一个字符串     </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>​		在代码运行时，变量的数据类型是由 JS引擎 根据 = 右边变量值的数据类型来判断 的，运行完毕之后， 变量就确定了数据类型。JavaScript 拥有动态类型，同时也意味着相同的变量可用作不同的类型：</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code></code></pre> <div class="line-numbers-wrapper"></div></div></li></ul> <p>var x = 6;           // x 为数字
var x = &quot;Bill&quot;;      // x 为字符串</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>
- 数据类型的分类

	JS 把数据类型分为两类：

- 简单数据类型 （Number,String,Boolean,Undefined,Null）

- 复杂数据类型 （object)	

### 8.2 简单数据类型

简单数据类型（基本数据类型）

JavaScript 中的简单数据类型及其说明如下：

![](images\图片16.png)

- 数字型 Number

​		JavaScript 数字类型既可以保存整数，也可以保存小数(浮点数）。  

```js
var age = 21;       // 整数
var Age = 21.3747;  // 小数     
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br></div></div><ol><li><p>数字型进制</p> <p>最常见的进制有二进制、八进制、十进制、十六进制。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>  <span class="token comment">// 1.八进制数字序列范围：0~7</span>
 <span class="token keyword">var</span> num1 <span class="token operator">=</span> <span class="token number">07</span><span class="token punctuation">;</span>   <span class="token comment">// 对应十进制的7</span>
 <span class="token keyword">var</span> num2 <span class="token operator">=</span> <span class="token number">019</span><span class="token punctuation">;</span>  <span class="token comment">// 对应十进制的19</span>
 <span class="token keyword">var</span> num3 <span class="token operator">=</span> <span class="token number">08</span><span class="token punctuation">;</span>   <span class="token comment">// 对应十进制的8</span>
  <span class="token comment">// 2.十六进制数字序列范围：0~9以及A~F</span>
 <span class="token keyword">var</span> num <span class="token operator">=</span> <span class="token number">0xA</span><span class="token punctuation">;</span>   
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>现阶段我们只需要记住，在JS中八进制前面加0，十六进制前面加 0x</p></li> <li><p>数字型范围</p> <p>JavaScript中数值的最大和最小值</p> <ul><li><p>最大值：Number.MAX_VALUE，这个值为： 1.7976931348623157e+308</p></li> <li><p>最小值：Number.MIN_VALUE，这个值为：5e-32</p></li></ul></li> <li><p>数字型三个特殊值</p> <ul><li><p>Infinity ，代表无穷大，大于任何数值</p></li> <li><p>-Infinity ，代表无穷小，小于任何数值</p></li> <li><p>NaN ，Not a number，代表一个非数值</p></li></ul></li> <li><p>isNaN</p> <p>用来判断一个变量是否为非数字的类型，返回 true 或者 false</p></li></ol> <p><img src="images%5C%E5%9B%BE%E7%89%8717.png" alt=""></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>  <span class="token keyword">var</span> usrAge <span class="token operator">=</span> <span class="token number">21</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> isOk <span class="token operator">=</span> <span class="token function">isNaN</span><span class="token punctuation">(</span>userAge<span class="token punctuation">)</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>isNum<span class="token punctuation">)</span><span class="token punctuation">;</span>          <span class="token comment">// false ，21 不是一个非数字</span>
<span class="token keyword">var</span> usrName <span class="token operator">=</span> <span class="token string">&quot;andy&quot;</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">isNaN</span><span class="token punctuation">(</span>userName<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">// true ，&quot;andy&quot;是一个非数字</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li><p>字符串型 String</p> <p>​		字符串型可以是引号中的任意文本，其语法为 双引号 &quot;&quot; 和 单引号''</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> strMsg <span class="token operator">=</span> <span class="token string">&quot;我爱北京天安门~&quot;</span><span class="token punctuation">;</span>  <span class="token comment">// 使用双引号表示字符串</span>
<span class="token keyword">var</span> strMsg2 <span class="token operator">=</span> <span class="token string">'我爱吃猪蹄~'</span><span class="token punctuation">;</span>    <span class="token comment">// 使用单引号表示字符串</span>
<span class="token comment">// 常见错误</span>
<span class="token keyword">var</span> strMsg3 <span class="token operator">=</span> 我爱大肘子<span class="token punctuation">;</span>       <span class="token comment">// 报错，没使用引号，会被认为是js代码，但js没有这些语法</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>​		因为 HTML 标签里面的属性使用的是双引号，JS 这里我们更推荐使用单引号。</p> <ol><li><p>字符串引号嵌套</p> <p>​		JS 可以用单引号嵌套双引号 ，或者用双引号嵌套单引号 (外双内单，外单内双)</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> strMsg <span class="token operator">=</span> <span class="token string">'我是&quot;高帅富&quot;程序猿'</span><span class="token punctuation">;</span>   <span class="token comment">// 可以用''包含&quot;&quot;</span>
<span class="token keyword">var</span> strMsg2 <span class="token operator">=</span> <span class="token string">&quot;我是'高帅富'程序猿&quot;</span><span class="token punctuation">;</span>  <span class="token comment">// 也可以用&quot;&quot; 包含''</span>
<span class="token comment">//  常见错误</span>
<span class="token keyword">var</span> badQuotes <span class="token operator">=</span> 'What on earth<span class="token operator">?</span>&quot;<span class="token punctuation">;</span> <span class="token comment">// 报错，不能 单双引号搭配</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li> <li><p>字符串转义符</p> <p>​		类似HTML里面的特殊字符，字符串中也有特殊字符，我们称之为转义符。</p> <p>​		转义符都是 \ 开头的，常用的转义符及其说明如下：</p> <table><thead><tr><th>转义符</th> <th>解释说明</th></tr></thead> <tbody><tr><td>\n</td> <td>换行符，n   是   newline   的意思</td></tr> <tr><td>\ \</td> <td>斜杠   \</td></tr> <tr><td>'</td> <td>'   单引号</td></tr> <tr><td>&quot;</td> <td>”双引号</td></tr> <tr><td>\t</td> <td>tab  缩进</td></tr> <tr><td>\b</td> <td>空格 ，b   是   blank  的意思</td></tr></tbody></table></li> <li><p>字符串长度</p> <p>​		字符串是由若干字符组成的，这些字符的数量就是字符串的长度。通过字符串的 length 属性可以获取整个字符串的长度。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> strMsg <span class="token operator">=</span> <span class="token string">&quot;我是帅气多金的程序猿！&quot;</span><span class="token punctuation">;</span>
<span class="token function">alert</span><span class="token punctuation">(</span>strMsg<span class="token punctuation">.</span>length<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 显示 11</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li> <li><p>字符串拼接</p> <ul><li><p>多个字符串之间可以使用 + 进行拼接，其拼接方式为 字符串 + 任何类型 = 拼接之后的新字符串</p></li> <li><p>拼接前会把与字符串相加的任何类型转成字符串，再拼接成一个新的字符串</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">//1.1 字符串 &quot;相加&quot;</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">'hello'</span> <span class="token operator">+</span> <span class="token string">' '</span> <span class="token operator">+</span> <span class="token string">'world'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// hello world</span>
<span class="token comment">//1.2 数值字符串 &quot;相加&quot;</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">'100'</span> <span class="token operator">+</span> <span class="token string">'100'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 100100</span>
<span class="token comment">//1.3 数值字符串 + 数值</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">'11'</span> <span class="token operator">+</span> <span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment">// 1112 </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><ul><li><em><strong>+ 号总结口诀：数值相加 ，字符相连</strong></em></li></ul></li></ul></li> <li><p>字符串拼接加强</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'pink老师'</span> <span class="token operator">+</span> <span class="token number">18</span><span class="token punctuation">)</span><span class="token punctuation">;</span>        <span class="token comment">// 只要有字符就会相连 </span>
<span class="token keyword">var</span> age <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'pink老师age岁啦'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>      <span class="token comment">// 这样不行哦</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'pink老师'</span> <span class="token operator">+</span> age<span class="token punctuation">)</span><span class="token punctuation">;</span>         <span class="token comment">// pink老师18</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'pink老师'</span> <span class="token operator">+</span> age <span class="token operator">+</span> <span class="token string">'岁啦'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// pink老师18岁啦</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>经常会将字符串和变量来拼接，变量可以很方便地修改里面的值</li> <li>变量是不能添加引号的，因为加引号的变量会变成字符串</li> <li>如果变量两侧都有字符串拼接，口诀“引引加加 ”，删掉数字，变量写加中间</li></ul></li></ol></li> <li><p>布尔型Boolean</p> <p>​		布尔类型有两个值：true 和 false ，其中 true 表示真（对），而 false 表示假（错）。</p> <p>​		布尔型和数字型相加的时候， true 的值为 1 ，false 的值为 0。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token boolean">true</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 2</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token boolean">false</span> <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 1</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li> <li><p>Undefined和 Null</p> <p>​		一个声明后没有被赋值的变量会有一个默认值undefined ( 如果进行相连或者相加时，注意结果）</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> variable<span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>variable<span class="token punctuation">)</span><span class="token punctuation">;</span>           <span class="token comment">// undefined</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'你好'</span> <span class="token operator">+</span> variable<span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 你好undefined</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token number">11</span> <span class="token operator">+</span> variable<span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment">// NaN</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token boolean">true</span> <span class="token operator">+</span> variable<span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">//  NaN</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>​		一个声明变量给 null 值，里面存的值为空（学习对象时，我们继续研究null)</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> vari <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'你好'</span> <span class="token operator">+</span> vari<span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 你好null</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token number">11</span> <span class="token operator">+</span> vari<span class="token punctuation">)</span><span class="token punctuation">;</span>     <span class="token comment">// 11</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token boolean">true</span> <span class="token operator">+</span> vari<span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">//  1</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li></ul> <h3 id="_8-3-获取变量数据类型"><a href="#_8-3-获取变量数据类型" class="header-anchor">#</a> 8.3 获取变量数据类型</h3> <ul><li><p>获取检测变量的数据类型</p> <p>​		typeof 可用来获取检测变量的数据类型</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">var</span> num <span class="token operator">=</span> <span class="token number">18</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">typeof</span> num<span class="token punctuation">)</span> <span class="token comment">// 结果 number      </span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>​		不同类型的返回值</p> <p><img src="images%5C%E5%9B%BE%E7%89%8718.png" alt=""></p></li> <li><p>字面量</p> <p>​		字面量是在源代码中一个固定值的表示法，通俗来说，就是字面量表示如何表达这个值。</p> <ul><li>数字字面量：8, 9, 10</li> <li>字符串字面量：'黑马程序员', &quot;大前端&quot;</li> <li>布尔字面量：true，false</li></ul></li></ul> <h3 id="_8-4-数据类型转换"><a href="#_8-4-数据类型转换" class="header-anchor">#</a> 8.4 数据类型转换</h3> <p>​		什么是数据类型转换？</p> <p>​		使用表单、prompt 获取过来的数据默认是字符串类型的，此时就不能直接简单的进行加法运算，而需要转换变量的数据类型。通俗来说，就是把一种数据类型的变量转换成另一种数据类型，通常会实现3种方式的转换：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>转换为字符串类型
转换为数字型
转换为布尔型
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li><p>转换为字符串</p> <p><img src="images%5C%E5%9B%BE%E7%89%8719.png" alt=""></p> <ul><li>toString() 和 String()  使用方式不一样。</li> <li>三种转换方式，更多第三种加号拼接字符串转换方式， 这一种方式也称之为隐式转换。</li></ul></li> <li><p>转换为数字型（重点）</p> <p><img src="images%5C%E5%9B%BE%E7%89%8720.png" alt=""></p> <ul><li>注意 parseInt 和 parseFloat 单词的大小写，这2个是重点</li> <li>隐式转换是我们在进行算数运算的时候，JS 自动转换了数据类型</li></ul></li> <li><p>转换为布尔型</p> <p><img src="images%5C%E5%9B%BE%E7%89%8721.png" alt=""></p> <ul><li><p>代表空、否定的值会被转换为 false  ，如 ''、0、NaN、null、undefined</p></li> <li><p>其余值都会被转换为 true</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token number">NaN</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token keyword">undefined</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token string">'小白'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">Boolean</span><span class="token punctuation">(</span><span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// true</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div></li></ul></li></ul> <h2 id="_9-解释型语言和编译型语言"><a href="#_9-解释型语言和编译型语言" class="header-anchor">#</a> 9 - 解释型语言和编译型语言</h2> <h3 id="_9-1-概述"><a href="#_9-1-概述" class="header-anchor">#</a> 9.1 概述</h3> <div class="language- extra-class"><pre><code>计算机不能直接理解任何除机器语言以外的语言，所以必须要把程序员所写的程序语言翻译成机器语言才能执行程序。程序语言翻译成机器语言的工具，被称为翻译器。
</code></pre></div><p><img src="images%5C%E5%9B%BE%E7%89%8722.png" alt=""></p> <ul><li>翻译器翻译的方式有两种：一个是编译，另外一个是解释。两种方式之间的区别在于翻译的时间点不同</li> <li>编译器是在代码执行之前进行编译，生成中间代码文件</li> <li>解释器是在运行时进行及时解释，并立即执行(当编译器以解释方式运行的时候，也称之为解释器)</li></ul> <h3 id="_9-2-执行过程"><a href="#_9-2-执行过程" class="header-anchor">#</a> 9.2 执行过程</h3> <p><img src="images%5C%E5%9B%BE%E7%89%8723.png" alt=""></p> <div class="language- extra-class"><pre><code>类似于请客吃饭：

	编译语言：首先把所有菜做好，才能上桌吃饭

	解释语言：好比吃火锅，边吃边涮，同时进行
</code></pre></div><h2 id="_10-关键字和保留字"><a href="#_10-关键字和保留字" class="header-anchor">#</a> 10 - 关键字和保留字</h2> <h3 id="_10-1-标识符"><a href="#_10-1-标识符" class="header-anchor">#</a> 10.1 标识符</h3> <div class="language- extra-class"><pre><code>标识(zhi)符：就是指开发人员为变量、属性、函数、参数取的名字。

标识符不能是关键字或保留字。
</code></pre></div><h3 id="_10-2-关键字"><a href="#_10-2-关键字" class="header-anchor">#</a> 10.2 关键字</h3> <div class="language- extra-class"><pre><code>关键字：是指 JS本身已经使用了的字，不能再用它们充当变量名、方法名。

包括：break、case、catch、continue、default、delete、do、else、finally、for、function、if、in、instanceof、new、return、switch、this、throw、try、typeof、var、void、while、with 等。
</code></pre></div><h3 id="_10-3-保留字"><a href="#_10-3-保留字" class="header-anchor">#</a> 10.3 保留字</h3> <div class="language- extra-class"><pre><code>保留字：实际上就是预留的“关键字”，意思是现在虽然还不是关键字，但是未来可能会成为关键字，同样不能使用它们当变量名或方法名。

包括：boolean、byte、char、class、const、debugger、double、enum、export、extends、fimal、float、goto、implements、import、int、interface、long、mative、package、private、protected、public、short、static、super、synchronized、throws、transient、volatile 等。

注意：如果将保留字用作变量名或函数名，那么除非将来的浏览器实现了该保留字，否则很可能收不到任何错误消息。当浏览器将其实现后，该单词将被看做关键字，如此将出现关键字错误。
</code></pre></div></div></section> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">5/2/2021, 11:14:27 PM</span></div></footer> <!----> <div class="comments-wrapper"><!----></div> <ul class="side-bar sub-sidebar-wrapper" style="width:12rem;" data-v-70334359><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_1-编程语言" class="sidebar-link reco-side-_1-编程语言" data-v-70334359>1 - 编程语言</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_1-1-编程" class="sidebar-link reco-side-_1-1-编程" data-v-70334359>1.1 编程</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_1-2-计算机语言" class="sidebar-link reco-side-_1-2-计算机语言" data-v-70334359>1.2 计算机语言</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_1-3-编程语言" class="sidebar-link reco-side-_1-3-编程语言" data-v-70334359>1.3 编程语言</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_1-4-翻译器" class="sidebar-link reco-side-_1-4-翻译器" data-v-70334359>1.4 翻译器</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_1-5-编程语言和标记语言区别" class="sidebar-link reco-side-_1-5-编程语言和标记语言区别" data-v-70334359>1.5 编程语言和标记语言区别</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#总结" class="sidebar-link reco-side-总结" data-v-70334359>总结</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_2-计算机基础" class="sidebar-link reco-side-_2-计算机基础" data-v-70334359>2 - 计算机基础</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_2-1-计算机组成" class="sidebar-link reco-side-_2-1-计算机组成" data-v-70334359>2.1 计算机组成</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_2-2-数据存储" class="sidebar-link reco-side-_2-2-数据存储" data-v-70334359>2.2 数据存储</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_2-3-数据存储单位" class="sidebar-link reco-side-_2-3-数据存储单位" data-v-70334359>2.3 数据存储单位</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_2-4-程序运行" class="sidebar-link reco-side-_2-4-程序运行" data-v-70334359>2.4 程序运行</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-初始javascript" class="sidebar-link reco-side-_3-初始javascript" data-v-70334359>3 - 初始JavaScript</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-1-javascript-是什么" class="sidebar-link reco-side-_3-1-javascript-是什么" data-v-70334359>3.1 JavaScript 是什么</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-2-javascript的作用" class="sidebar-link reco-side-_3-2-javascript的作用" data-v-70334359>3.2 JavaScript的作用</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-3-html-css-js-的关系" class="sidebar-link reco-side-_3-3-html-css-js-的关系" data-v-70334359>3.3 HTML/CSS/JS 的关系</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-4-浏览器执行-js-简介" class="sidebar-link reco-side-_3-4-浏览器执行-js-简介" data-v-70334359>3.4 浏览器执行 JS 简介</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-5-js-的组成" class="sidebar-link reco-side-_3-5-js-的组成" data-v-70334359>3.5 JS 的组成</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_3-6-js-初体验" class="sidebar-link reco-side-_3-6-js-初体验" data-v-70334359>3.6 JS 初体验</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_4-javascript注释" class="sidebar-link reco-side-_4-javascript注释" data-v-70334359>4 - JavaScript注释</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_4-1-单行注释" class="sidebar-link reco-side-_4-1-单行注释" data-v-70334359>4.1  单行注释</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_4-2-多行注释" class="sidebar-link reco-side-_4-2-多行注释" data-v-70334359>4.2 多行注释</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_5-javascript输入输出语句" class="sidebar-link reco-side-_5-javascript输入输出语句" data-v-70334359>5 - JavaScript输入输出语句</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_6-变量的概念" class="sidebar-link reco-side-_6-变量的概念" data-v-70334359>6 - 变量的概念</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_6-1-什么是变量" class="sidebar-link reco-side-_6-1-什么是变量" data-v-70334359>6.1 什么是变量</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_6-2-变量在内存中的存储" class="sidebar-link reco-side-_6-2-变量在内存中的存储" data-v-70334359>6.2 变量在内存中的存储</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_7-变量的使用" class="sidebar-link reco-side-_7-变量的使用" data-v-70334359>7 - 变量的使用</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_7-1-声明变量" class="sidebar-link reco-side-_7-1-声明变量" data-v-70334359>7.1 声明变量</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_7-2-赋值" class="sidebar-link reco-side-_7-2-赋值" data-v-70334359>7.2 赋值</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_7-3-变量的初始化" class="sidebar-link reco-side-_7-3-变量的初始化" data-v-70334359>7.3 变量的初始化</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_7-4-变量语法扩展" class="sidebar-link reco-side-_7-4-变量语法扩展" data-v-70334359>7.4 变量语法扩展</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_7-5-变量命名规范" class="sidebar-link reco-side-_7-5-变量命名规范" data-v-70334359>7.5 变量命名规范</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_8-数据类型" class="sidebar-link reco-side-_8-数据类型" data-v-70334359>8 - 数据类型</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_8-1-数据类型简介" class="sidebar-link reco-side-_8-1-数据类型简介" data-v-70334359>8.1 数据类型简介</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_8-3-获取变量数据类型" class="sidebar-link reco-side-_8-3-获取变量数据类型" data-v-70334359>8.3 获取变量数据类型</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_8-4-数据类型转换" class="sidebar-link reco-side-_8-4-数据类型转换" data-v-70334359>8.4 数据类型转换</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_9-解释型语言和编译型语言" class="sidebar-link reco-side-_9-解释型语言和编译型语言" data-v-70334359>9 - 解释型语言和编译型语言</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_9-1-概述" class="sidebar-link reco-side-_9-1-概述" data-v-70334359>9.1 概述</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_9-2-执行过程" class="sidebar-link reco-side-_9-2-执行过程" data-v-70334359>9.2 执行过程</a></li><li class="level-2" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_10-关键字和保留字" class="sidebar-link reco-side-_10-关键字和保留字" data-v-70334359>10 - 关键字和保留字</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_10-1-标识符" class="sidebar-link reco-side-_10-1-标识符" data-v-70334359>10.1 标识符</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_10-2-关键字" class="sidebar-link reco-side-_10-2-关键字" data-v-70334359>10.2 关键字</a></li><li class="level-3" data-v-70334359><a href="/Blogs/blogs/qianduan/JavaScript/JavaScript.html#_10-3-保留字" class="sidebar-link reco-side-_10-3-保留字" data-v-70334359>10.3 保留字</a></li></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div></div></div>
    <script src="/Blogs/assets/js/app.f9a70f72.js" defer></script><script src="/Blogs/assets/js/3.e5a0ba5b.js" defer></script><script src="/Blogs/assets/js/1.1a4801d9.js" defer></script><script src="/Blogs/assets/js/16.736c5c7b.js" defer></script>
  </body>
</html>
